package rsb21424yhc.d1118;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/*
姓名 学号 英语
唐凯悦 41926081 90 真住 41926084 78 41926022 91龙 41926010 87安典 41926038 91泽轩 41926006 92姚之涵 41926077 92
韩学敏 41926015 91母奉泽 41926020 92刘立奇 41926025 90张小艳 41926013 89徐奥 41926079 91
 */
public class Tools {
    public  static double getAvg(List<Student> list){
        double sum=0;
        Iterator <Student> it= list.iterator();
        while (it.hasNext()){
            Student stu=it.next();
            sum+=stu.getMark();
        }

        return sum/list.size();
    }
    public static double getMax(List<Student> list) {
        double max = 0;
        //Iterator<Student> it =list.iterator();
        //Student stuMax= it.next();//指针移动 迭代器移动 假设第一个是最高的学生
        /*
        while (it.hasNext()){
        Student stu =it.next();
        if(stu.getScore()>stuMax.getScore()){
        stuMax=stu}}
         */
        //return stuMax;

        /*
        Demo02.Person p=list.get(i);
            if (!p.getCountry().equals("m")){
                list.remove(i);
         */

        for (int i=0; i<list.size();i++) {
            Student stu =list.get(i);//逐个传 对象
            if (stu.getMark()>max){
                max=stu.getMark();
            }
        }
        return max;
    }
    public static  List<Student> getBl60(List<Student> list,int x) {//可变长度的容器---集合arraylist
        int l=list.size();
        List<Student> listbl60=new ArrayList<>();
        for (Student stud:list){
            if (stud.getMark()<x){
                listbl60.add(stud);

            }

        }return listbl60;}/*
    public static double getAvg(List<Student> list, int x) {//可变长度的容器---集合arraylist
        int l=list.size();
        double sum=0;
        List<chap04.r21403.d1123.Student> listbl60=new ArrayList<>();
        for (int i=0;i<l;i++){
            Student stud=list.get(i);//无用的方法

                list.remove(i);
            sum=stud.getMark();

        }return sum;}*/
}








        /*
       Iterator <Student> stufall=list.iterator();
        ArrayList<String> arrayList =new ArrayList();
        while (stufall.hasNext()){
            Student stud =stufall.next();//逐个传 对象
            if (stud.getMark()<60){

        }
        return stud;
    }*/
        /*
        ArrayList<String> arrayList =new ArrayList();


        for (int i=0; i<l;i++) {
            Student stu =list.get(i);//逐个传 对象
            if (stu.getMark()<60){
                //score=stu.getMark();
                arrayList.add( stu.getId());
                arrayList.add(stu.getName());
                arrayList.add(String.valueOf(stu.getMark()));
            }

        }
        //System.out.println(arrayList);
            return (Student) list;
    }*/


